/**
 * Copyright (C) Octlan Corporation. All rights reserved.
 * 
 * @author todzhang
 * @date 2010-12-14
 * @version $Id: TextViewActivity.java 20 2010-12-17 07:24:32Z todzhang $
 */
package com.octlan.asynctasklea;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.view.View;

public class TextViewActivity extends Activity implements TextLinkClickListener {

	private LinkEnabledTextView check;
	protected void onCreate(Bundle savedInstance)
	{
	    super.onCreate(savedInstance);

	    String text  =  "This is a #test of regular expressions with http://example.com links as used in @twitter  for performing various operations based on the links this handles multiple links like http://this_is_fun.com and #Awesomess and @Cool";
	    check = new LinkEnabledTextView(this, null);
	    check.setOnTextLinkClickListener(this);
	    check.gatherLinksForText(text);
	    check.setTextColor(Color.WHITE);
	    check.setLinkTextColor(Color.GREEN);

	    MovementMethod m = check.getMovementMethod();
	    if ((m == null) || !(m instanceof LinkMovementMethod)) {
	        if (check.getLinksClickable()) {
	            check.setMovementMethod(LinkMovementMethod.getInstance());
	        }
	    }

	    setContentView(check);
	}

	public void onTextLinkClick(View textView, String clickedString)
	{
	    android.util.Log.v("Hyperlink clicked is :: " + clickedString, "Hyperlink clicked is :: " + clickedString);
	}

}
